package com.ltkj.baseplatform.controller;

import com.ltkj.baseplatform.domain.SerGameData;
import com.ltkj.baseplatform.domain.SerGameType;
import com.ltkj.baseplatform.domain.bo.SerGameMemberBo;
import com.ltkj.baseplatform.domain.bo.SerGameMemberQueryBo;
import com.ltkj.baseplatform.domain.vo.SerGameDataVo;
import com.ltkj.baseplatform.domain.vo.SerGameMemberVo;
import com.ltkj.baseplatform.service.ISerGameDataService;
import com.ltkj.baseplatform.service.ISerGameMemberService;
import com.ltkj.baseplatform.service.ISerGameTypeService;
import com.ltkj.common.core.web.controller.BaseController;
import com.ltkj.common.core.web.domain.AjaxResult;
import com.ltkj.common.core.web.page.TableDataInfo;
import com.ltkj.common.log.annotation.Log;
import com.ltkj.common.log.enums.BusinessType;
import com.ltkj.common.security.annotation.RequiresPermissions;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 小程序赛事管理Controller
 * @author liupf
 * @date 2023-09-15
 */
@Api(tags = "小程序赛事管理")
@RestController
@RequestMapping("/applet/game")
public class AppletGameManageController extends BaseController
{
    @Autowired
    private ISerGameMemberService serGameMemberService;
    @Autowired
    private ISerGameDataService serGameDataService;
    @Autowired
    private ISerGameTypeService serGameTypeService;

    /**
     * 查询游记管理列表
     */
    @ApiOperation("查询赛事分类列表")
    @GetMapping("/type/list")
    public TableDataInfo typeList(SerGameType serGameType)
    {
        startPage();
        List<SerGameType> list = serGameTypeService.selectSerGameTypeList(serGameType);
        return getDataTable(list);
    }

    /**
     * 查询赛事列表
     */
    @ApiOperation("查询赛事列表")
    @GetMapping("/list")
    public TableDataInfo gameList(SerGameData serGameData)
    {
        startPage();
        List<SerGameDataVo> list = serGameDataService.selectSerGameDataAppletList(serGameData);
        return getDataTable(list);
    }

    /**
     * 查询赛事列表
     */
    @ApiOperation("查询我的赛事列表")
    @GetMapping("/my/list")
    public TableDataInfo myGameList()
    {
        startPage();
        List<SerGameDataVo> list = serGameDataService.selectMySerGameDataList();
        return getDataTable(list);
    }

    /**
     * 获取赛事详细信息
     */
    @ApiOperation("获取赛事详细信息")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(serGameDataService.selectSerGameDataVoById(id));
    }
    /**
     * 查询赛事成员列表
     */
    /*@ApiOperation("查询赛事成员列表")
    @GetMapping("/member/list")
    public TableDataInfo memberList(SerGameMemberQueryBo serGameMemberQueryBo)
    {
        startPage();
        List<SerGameMemberVo> list = serGameMemberService.selectSerGameMemberVoList(serGameMemberQueryBo);
        return getDataTable(list);
    }*/

    /**
     * 新增赛事成员
     */
    /*@ApiOperation("新增赛事成员")
    @Log(title = "赛事成员", businessType = BusinessType.INSERT)
    @PostMapping("/add/member")
    public AjaxResult add(@Validated @RequestBody SerGameMemberBo serGameMember)
    {
        return toAjax(serGameMemberService.insertSerGameMember(serGameMember));
    }*/

    /**
     * 新增赛事成员
     */
    @ApiOperation("批量新增赛事成员")
    @Log(title = "赛事成员", businessType = BusinessType.INSERT)
    @PostMapping("/add/members")
    public AjaxResult addBatch(@RequestBody List<SerGameMemberBo> serGameMembers)
    {
        Long gameId = serGameMemberService.validateGameMember(serGameMembers);
        return toAjax(serGameMemberService.insertSerGameMemberBacth(serGameMembers,gameId));
    }

    /**
     * 获取赛事详细信息
     */
    @ApiOperation("获取报名赛事详细信息")
    @GetMapping(value = "/detail/{id}")
    public AjaxResult getDetailInfo(@PathVariable("id") Long id)
    {
        return success(serGameDataService.selectSerGameDetailById(id));
    }
}
